package engine.profile
{
	import engine.core.*;
	import flash.system.*;
	
	public class RxMemoryProfileData extends RxProfileData
	{
		private var m_freeMemoryProfileData:RxProfileData;
		
		public function RxMemoryProfileData()
		{
			m_freeMemoryProfileData = new RxProfileData();
		}
		
		override public function Start(param1:String, param2:int) : void
		{
			super.Start(param1, param2);
			m_valueStart = System.totalMemoryNumber;
			this.m_freeMemoryProfileData.Start(param1, param2);
			this.m_freeMemoryProfileData.m_valueStart = System.freeMemory;
		}
		
		override public function End() : void
		{
			m_valueEnd = System.totalMemoryNumber;
			this.m_freeMemoryProfileData.m_valueEnd = System.freeMemory;
			super.End();
			this.m_freeMemoryProfileData.End();
		}
		
		override public function Snapshot(param1:String) : void
		{
			super.Snapshot(param1);
			m_valueStart = System.totalMemoryNumber;
			this.m_freeMemoryProfileData.m_valueStart = System.freeMemory;
		}
		
		override public function ConvertToString(param1:Boolean, param2:Boolean, param3:uint) : String
		{
			var _loc_7:Number = NaN;
			var _loc_8:Number = NaN;
			var result:String = "";
			var _loc_5:String = "";
			if (m_valueCount == -1)
			{
				result = result + (m_name + ": total: " + RxUtilities.scvt(m_valueStart, param3) + ", free: " + RxUtilities.scvt(this.m_freeMemoryProfileData.m_valueStart, param3));
				return result;
			}
			
			var i:int = 0;
			while (i < m_stackDepth)
			{
				
				_loc_5 = _loc_5 + "-";
				i++;
			}
			_loc_5 = _loc_5 + " ";
			if (param1)
			{
				result = result + (_loc_5 + m_name + ":\n");
				result = result + (_loc_5 + "  start: total: " + RxUtilities.scvt(m_valueStart, param3) + ", free: " + RxUtilities.scvt(this.m_freeMemoryProfileData.m_valueStart, param3) + "\n");
				result = result + (_loc_5 + "  end: total: " + RxUtilities.scvt(m_valueEnd, param3) + ", free: " + RxUtilities.scvt(this.m_freeMemoryProfileData.m_valueEnd, param3) + "\n");
				result = result + (_loc_5 + "  delta: total: " + RxUtilities.scvt(m_valueEnd - m_valueStart, param3) + ", free: " + RxUtilities.scvt(this.m_freeMemoryProfileData.m_valueEnd - this.m_freeMemoryProfileData.m_valueStart, param3) + "\n");
			}
			else
			{
				_loc_7 = param2 ? (m_valueAverage) : (m_valueEnd - m_valueStart);
				_loc_8 = param2 ? (this.m_freeMemoryProfileData.m_valueAverage) : (this.m_freeMemoryProfileData.m_valueEnd - this.m_freeMemoryProfileData.m_valueStart);
				result = result + (_loc_5 + m_name + ": total: " + RxUtilities.scvt(_loc_7, param3) + ", free: " + RxUtilities.scvt(_loc_8, param3));
			}
			
			return result;
		}
	}
}